import 'file:///D:/my_workspace/atc_flutter/lib/home/message/message_page.dart';
import 'file:///D:/my_workspace/atc_flutter/lib/home/my/my_page.dart';
import 'file:///D:/my_workspace/atc_flutter/lib/home/bench/work_bench_page.dart';
import 'package:flutter/material.dart';

/// 首页
class MainPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return MainState();
  }
}

class MainState extends State<MainPage> {
  int _curSelected = 0;
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: _getWidgetByIndex(_curSelected),
        bottomNavigationBar: BottomNavigationBar(
          items: [
            BottomNavigationBarItem(icon: Icon(Icons.home), title: Text("工作台")),
            BottomNavigationBarItem(icon: Icon(Icons.message), title: Text("消息")),
            BottomNavigationBarItem(icon: Icon(Icons.person), title: Text("我的"))
          ],
          currentIndex: _curSelected,
          onTap: (index) {
            setState(() {
              _curSelected = index;
            });
          },
        ),
      ),

    );
  }

  Widget _getWidgetByIndex(int curSelected) {
    switch (curSelected) {
      case 1:
        return MessagePage();
      case 2:
        return MyPage();
      case 0:
      default:
        return WorkBenchPage();
    }
  }
}
